package com.sinoglobal.ningxia.downdata.imp;

import android.content.Context;
import android.text.SpannableString;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.sinoglobal.networkconnections.HttpTools;
import com.sinoglobal.ningxia.beans.AcceptPrizeInfoVo;
import com.sinoglobal.ningxia.beans.AdverVo;
import com.sinoglobal.ningxia.beans.AmusementInfoVo;
import com.sinoglobal.ningxia.beans.AmusementListVo;
import com.sinoglobal.ningxia.beans.AnswerRule;
import com.sinoglobal.ningxia.beans.AnswerSourceVo;
import com.sinoglobal.ningxia.beans.AreaListVo;
import com.sinoglobal.ningxia.beans.BillVo;
import com.sinoglobal.ningxia.beans.BroadCastVo;
import com.sinoglobal.ningxia.beans.BusinessDetailVo;
import com.sinoglobal.ningxia.beans.CommentIdVo;
import com.sinoglobal.ningxia.beans.CommentListVo;
import com.sinoglobal.ningxia.beans.CommentSubmitVo;
import com.sinoglobal.ningxia.beans.ConsigneeInfoVo;
import com.sinoglobal.ningxia.beans.EasyFunBeginVo;
import com.sinoglobal.ningxia.beans.EasyFunEndVo;
import com.sinoglobal.ningxia.beans.EnentCodeVo;
import com.sinoglobal.ningxia.beans.EnentItemVo;
import com.sinoglobal.ningxia.beans.EnentsActivityVo;
import com.sinoglobal.ningxia.beans.EnentsListVo;
import com.sinoglobal.ningxia.beans.GoodsOrderInfoVo;
import com.sinoglobal.ningxia.beans.HomeInfoVo;
import com.sinoglobal.ningxia.beans.InteractionAnswerListVo;
import com.sinoglobal.ningxia.beans.LoadingVo;
import com.sinoglobal.ningxia.beans.LockingCheck;
import com.sinoglobal.ningxia.beans.LoginVo;
import com.sinoglobal.ningxia.beans.MessageVo;
import com.sinoglobal.ningxia.beans.MicChannelListVo;
import com.sinoglobal.ningxia.beans.MicProgramBean;
import com.sinoglobal.ningxia.beans.MyActivityVo;
import com.sinoglobal.ningxia.beans.MyCollectionDataVo;
import com.sinoglobal.ningxia.beans.MyCollectionRefreshVo;
import com.sinoglobal.ningxia.beans.MyCouponsActivityVo;
import com.sinoglobal.ningxia.beans.MyGoodVo;
import com.sinoglobal.ningxia.beans.MyPrizeVo;
import com.sinoglobal.ningxia.beans.NewsDetailVo;
import com.sinoglobal.ningxia.beans.NewsListVo;
import com.sinoglobal.ningxia.beans.NewsSectionListVo;
import com.sinoglobal.ningxia.beans.PhotoWallVo;
import com.sinoglobal.ningxia.beans.ProgramListVo;
import com.sinoglobal.ningxia.beans.RegistVo;
import com.sinoglobal.ningxia.beans.RootVo;
import com.sinoglobal.ningxia.beans.ShallShopGoodActivityVo;
import com.sinoglobal.ningxia.beans.ShallShopIndexActivityVo;
import com.sinoglobal.ningxia.beans.ShareAndPushVo;
import com.sinoglobal.ningxia.beans.SysMessageListVo;
import com.sinoglobal.ningxia.beans.TurntableGainVo;
import com.sinoglobal.ningxia.beans.TurntableInfoVo;
import com.sinoglobal.ningxia.beans.TurntableResultVo;
import com.sinoglobal.ningxia.beans.UserBean;
import com.sinoglobal.ningxia.beans.UserImageVo;
import com.sinoglobal.ningxia.beans.UserInfoVo;
import com.sinoglobal.ningxia.beans.VersionVo;
import com.sinoglobal.ningxia.downdata.api.IRemote;
import com.sinoglobal.ningxia.frame.FlyApplication;
import com.sinoglobal.ningxia.http.ConnectionUtil;
import com.sinoglobal.ningxia.utils.LocalCache;
import com.sinoglobal.ningxia.utils.MContants;
import com.sinoglobal.ningxia.utils.SharedPreferenceUtil;
import com.sinoglobal.ningxia.utils.TextUtil;
import com.zhy.http.okhttp.request.RequestCall;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class RemoteImpl implements IRemote {
    private static IRemote remote;
    String arrival, endDay;

    private RemoteImpl() {
    }

    static {
        remote = new RemoteImpl();
    }

    public static IRemote getInstance() {
        return remote;
    }

	/*
     * @Override public ColumnListVo getColumnList() throws Exception { //
	 * Map<String, Object> params = new LinkedHashMap<String, Object>(); String
	 * json = ConnectionUtil.send(false, "getDefNewsCol", "get"); return
	 * JSON.parseObject(json, ColumnListVo.class); // return
	 * JSON.parseObject(TestJson.getColumnList(), // ColumnListVo.class);
	 * 
	 * }
	 */

    /*
     * {@see com.sinoglobal.ningxia.service.api.IRemote#getUserInfo()}
     */
    @Override
    public UserBean getUserInfo() throws Exception {
        return null;
    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-2 下午3:24:28
     * @Description:启动页请求接口
     * @type get方式
     * @parameters 不需要参数
     */
    @Override
    public LoadingVo getLoading() throws Exception {
        String por = "por=809";// 请求接口类型
        String requestUrl = por;
        String json = ConnectionUtil.send(false, requestUrl, "get", null);
        return JSON.parseObject(json, LoadingVo.class);
    }

    /*
     * {@see com.sinoglobal.ningxia.downdata.api.IRemote#getSysMessage(int)}
     */
    @Override
    public SysMessageListVo getSysMessage(String userid) {
        return null;
    }

    @Override
    public HomeInfoVo getHomeInfo(Boolean cache, String parameter)
            throws Exception {

        String json = ConnectionUtil.send(cache, parameter, "get", null);
        Log.e("json", parameter + "======" + json);
        return JSON.parseObject(json, HomeInfoVo.class);
    }

    @Override
    public MyActivityVo getMyActivityVo(String userid) throws Exception {
        String params = "por=303" + "&userid=" + userid;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, MyActivityVo.class);
        // return JSON.parseObject(TestJson.getMyActivityInfo(),
        // MyActivityVo.class);
    }

    @Override
    public EnentsActivityVo getEnentsActivityVo() throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "801");
        params.put("goods_id", "2");
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, EnentsActivityVo.class);

        // String enentsActivityVo = TestJson.getEnentsActivityVo();
        // return JSON.parseObject(enentsActivityVo, EnentsActivityVo.class);
    }

    @Override
    public ShallShopGoodActivityVo getGoodActivityVo(String type,
                                                     String goods_id) throws Exception {
        // String params = "por=801" + "&type=" + type + "&goods_id=" +
        // goods_id;
        // String json = ConnectionUtil.send(false, params, "get", null);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "801");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        params.put("goods_id", goods_id);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, ShallShopGoodActivityVo.class);
    }

    // @Override
    // public ShallShopGoodActivityVo getGoodActivityVo() throws Exception {
    // Map<String, Object> params = new HashMap<String, Object>();
    // params.put("por", "801");
    // String json1 = ConnectionUtil.post(params);
    // return JSON.parseObject(json1, ShallShopGoodActivityVo.class);
    //
    // // String enentsActivityVo = TestJson.getEnentsActivityVo();
    // // return JSON.parseObject(enentsActivityVo, EnentsActivityVo.class);
    // }
    // city参数为无用参数，后台没做处理
    @Override
    public AreaListVo getAreaListVo(String type, String city) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "400");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        if (city != null)
            params.put("city", city);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, AreaListVo.class);
        // return JSON.parseObject(TestJson.getAreaListVo(), AreaListVo.class);
    }

    @Override
    public AmusementListVo getAmusementListVo(String type, String quyu,
                                              String classid, String star, String juli, String pagenum,
                                              String limit) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "401");
        params.put("type", type);
        params.put("quyu", quyu);
        params.put("classid", classid);
        params.put("star", star);
        params.put("juli", juli);
        params.put("latitude", FlyApplication.latitude);
        params.put("longitude", FlyApplication.longitude);
        params.put("limit1", pagenum);
        params.put("limit2", limit);
        params.put("userid", FlyApplication.userId);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, AmusementListVo.class);
        // return JSON.parseObject(TestJson.getAmusementListVo(),
        // AmusementListVo.class);
    }

    @Override
    public CommentListVo getBusinessCommentList(String shopId, int pageNum)
            throws Exception {
        Map<String, Object> params = new LinkedHashMap<String, Object>();
        params.put("por", "404");
        params.put("userid", FlyApplication.userId);
        params.put("id", shopId);
        params.put("limit1", pageNum + "");
        params.put("limit2", "8");
        String json = ConnectionUtil.post("", params);
        // String json = TestJson.getBusinessCommentList();
        return JSON.parseObject(json, CommentListVo.class);
    }

    @Override
    public AmusementListVo getSettleDownList(String quyu, String price,
                                             String pagenum, String limit) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "407");
        params.put("quyu", quyu);
        params.put("price", price);
        params.put("latitude", FlyApplication.latitude);
        params.put("longitude", FlyApplication.longitude);
        params.put("limit1", pagenum);
        params.put("limit2", limit);
        params.put("userid", FlyApplication.userId);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, AmusementListVo.class);
        // return JSON.parseObject(TestJson.getSettleDownList(),
        // AmusementListVo.class);
    }

    @Override
    public CommentIdVo submitComment(CommentSubmitVo commentInfo,
                                     Context context) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();

        params.put("por", "106");
        params.put("userid", FlyApplication.userId);
        params.put("type", commentInfo.getType());
        params.put("id", commentInfo.getId());
        SpannableString spring = new SpannableString(commentInfo.getContent());
        params.put("content", spring);
        params.put("star", commentInfo.getStar());
        params.put("username",
                SharedPreferenceUtil.getString(context, "username"));
        params.put("nickname",
                SharedPreferenceUtil.getString(context, "nickname"));
        String json = ConnectionUtil.post("", params);
        // return JSON.parseObject(json, Youhui_list_Vo.class);
        return JSON.parseObject(json, CommentIdVo.class);
    }

    @Override
    public BusinessDetailVo getBusinessDetailVo(String shopId, String typeId)
            throws Exception {
        Map<String, Object> params = new LinkedHashMap<String, Object>();
        params.put("por", "403");
        // FIXME 确定该应用用的是哪个userid
        params.put("userid", FlyApplication.userId);
        params.put("shopid", shopId);
        params.put("typeid", typeId);
        String json = ConnectionUtil.post("", params);
        // String json = TestJson.getBusinessDetailVo();
        return JSON.parseObject(json, BusinessDetailVo.class);
    }

    @Override
    public PhotoWallVo getPhotoWall(String pageNum, String shopId)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "405");
        params.put("userid", FlyApplication.userId);
        params.put("shopid", shopId);
        params.put("limit1", pageNum + "");
        params.put("limit2", "8");

        // String json = ConnectionUtil.post("", params);
        // String json = TestJson.getPhotoWallVo();

        String json = ConnectionUtil.post("", params);
        // String json = TestJson.getPhotoWallVo();
        return JSON.parseObject(json, PhotoWallVo.class);
    }

    @Override
    public EnentsListVo getEnentsListyVo(String type, int pageNum)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "300");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        params.put("limit1", pageNum + "");
        params.put("limit2", "5");
        String json = ConnectionUtil.send(false, "", "post", params);
        // String requestPor = "por=300" + "&userid=" + userid + "&type=" +
        // type;// 请求接口类型
        // String json = ConnectionUtil.send(false, requestPor, "get", null);
        return JSON.parseObject(json, EnentsListVo.class);
    }

    @Override
    public AmusementInfoVo getSettleDownDetails(String houseid)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "408");
        params.put("houseid", houseid);
        params.put("userid", FlyApplication.userId);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, AmusementInfoVo.class);
        // return JSON.parseObject(TestJson.getSettleDownDetails(),
        // AmusementInfoVo.class);
    }

    @Override
    public MyCollectionDataVo getMyCollectionDataVo(String userid, String type,
                                                    String limit1, String limit2) throws Exception {
        String params = "por=502" + "&userid=" + userid + "&type=" + type
                + "&limit1=" + limit1 + "&limit2=" + limit2;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, MyCollectionDataVo.class);
    }

    @Override
    public LoginVo login(String phoneStr, String pwdStr) throws Exception {
//		String params = "por=1000" + "&username=" + phoneStr + "&pwd=" + pwdStr;
//		String json = ConnectionUtil.send(false, params, "get", null);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1000");
        params.put("username", phoneStr);
        params.put("pwd", pwdStr);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, LoginVo.class);
    }

    @Override
    public AmusementListVo getAmusementListSearch(String type, String content,
                                                  String limit1, String limit2) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "402");
        params.put("type", type);
        params.put("content", content);
        params.put("latitude", FlyApplication.latitude);
        params.put("longitude", FlyApplication.longitude);
        params.put("limit1", limit1);
        params.put("limit2", limit2);
        params.put("userid", FlyApplication.userId);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, AmusementListVo.class);
        // return JSON.parseObject(TestJson.getSettleDownList(),
        // AmusementListVo.class);
    }

    @Override
    public RootVo deleteMyActivity(String userid, String id) throws Exception {
        String params = "por=304" + "&userid=" + userid + "&id=" + id;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public RootVo getRegistUserCode(String phoneNum) throws Exception {
        String params = "por=1005" + "&username=" + phoneNum;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public RegistVo regist(String username, String nickname, String password)
            throws Exception {
        //下载渠道id
        String channelId;
        channelId = SharedPreferenceUtil.getString(FlyApplication.context, MContants.CHANNEL_ID);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1001");
        params.put("username", username);
        params.put("nickname", nickname);
        params.put("pwd", password);
        params.put("channel ", channelId);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, RegistVo.class);
    }

	/*
     * @Override public RootVo registValidCode(String phone, String codeStr)
	 * throws Exception { // String params = "por=1006" + "&code=" +code;
	 * Map<String, Object> params = new HashMap<String, Object>();
	 * params.put("por", "1006"); params.put("username", phone);
	 * params.put("code", codeStr); String json = ConnectionUtil.post("",
	 * params); // String json = ConnectionUtil.send(false, null, "post",
	 * params); return JSON.parseObject(json, RootVo.class); }
	 */

    @Override
    public RootVo saveUserModifyInfo(String id, String username,
                                     String nickname, String sex, String email) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "903");
        params.put("userid", id);
        params.put("username", username);
        params.put("nickname", nickname);
        params.put("sex", sex);
        params.put("email", email);
        // String params = "por=903" + "&userid=" + id + "&username=" + username
        // + "&nickname=" + nickname + "&sex=" + sex + "&email=" + email;
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, RootVo.class);
    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-5 上午9:50:47
     * @Description:获取微视听频道信息
     * @type
     * @parameters
     */
    @Override
    public MicChannelListVo getMicChannelList(String userid) throws Exception {
        String requestPor = "por=200";// 请求接口类型
        if (userid != null && !userid.equals(""))
            requestPor = requestPor + "&userid=" + userid;
        String json = ConnectionUtil.send(false, requestPor, "get", null);
        MicChannelListVo vo = JSON.parseObject(json, MicChannelListVo.class);
        return JSON.parseObject(json, MicChannelListVo.class);
    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-5 下午2:45:19
     * @Description: 节目列表，
     * @type
     * @parameters 获取该节目每期节目列表，参数是节目id
     */
    @Override
    public ProgramListVo getMicProgramList(String programId, byte limit1,
                                           byte limit2) throws Exception {
        // Auto-generated method stub
        String requestPor = "por=201" + "&programId=" + programId + "&limit1="
                + limit1;// 请求接口类型
        if (limit2 != 0)
            requestPor = requestPor + "&limit2=" + limit2;
        String json = ConnectionUtil.send(false, requestPor, "get", null);
        return JSON.parseObject(json, ProgramListVo.class);
    }

    @Override
    public RootVo getFindPwdCode(String phoneNum) throws Exception {
        String params = "por=1002" + "&username=" + phoneNum;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public RootVo changePwd(String username, String oldPwd, String newPwd)
            throws Exception {
//		String params = "por=1009" + "&username=" + username + "&old_pwd="
//				+ oldPwd + "&pwd=" + newPwd;
//		String json = ConnectionUtil.send(false, params, "get", null);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1009");
        params.put("username", username);
        params.put("old_pwd", oldPwd);
        params.put("pwd", newPwd);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public RootVo validCode(String username, int type, String code)
            throws Exception {
        String params = "por=1003" + "&username=" + username + "&type=" + type
                + "&code=" + code;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public RootVo modifyPwd(String username, String pwd) throws Exception {
//		String params = "por=1004" + "&username=" + username + "&pwd=" + pwd;
//		String json = ConnectionUtil.send(false, params, "get", null);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1004");
        params.put("username", username);
        params.put("pwd", pwd);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, RootVo.class);
    }

    /**
     *
     */
    @Override
    public ShallShopIndexActivityVo getIndexActivityVo(String type, int pageNum)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "800");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        params.put("limit1", pageNum);
        params.put("limit2", "8");
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, ShallShopIndexActivityVo.class);
    }

    @Override
    public MyCouponsActivityVo getMyCouponsActivityVo(String type)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "803");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, MyCouponsActivityVo.class);

    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-7 上午10:05:06
     * @Description:
     * @type
     * @parameters action 1代表收藏，2代表删除； type：
     * <p>
     * 收藏类型 1娱乐 2美食 3新闻 4栏目 5安居
     */
    @Override
    public RootVo add2DelCollect(String userid, byte type, byte action,
                                 String Id) throws Exception {
        String requestPor = "por=501";
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "501");
        params.put("userid", userid);
        params.put("type", type);
        params.put("action", action);
        params.put("id", Id);
        String json = ConnectionUtil.send(false, null, "post", params);
        return JSON.parseObject(json, RootVo.class);

    }

    @Override
    public AnswerRule getAnswerRule(String id) throws Exception {
        String requestPor = "por=1100&userid=" + FlyApplication.userId;
        String json = ConnectionUtil.send(false, requestPor, "get", null);
        return JSON.parseObject(json, AnswerRule.class);

        // return JSON.parseObject(TestJson.getAnswerRule(), AnswerRule.class);
    }

    @Override
    public InteractionAnswerListVo getAnswerList(String id) throws Exception {
        String requestPor = "por=1101&userid=" + FlyApplication.userId;
        String json = ConnectionUtil.send(false, requestPor, "get", null);
        return JSON.parseObject(json, InteractionAnswerListVo.class);

        // return JSON.parseObject(TestJson.getAnswerList(),
        // InteractionAnswerListVo.class);
    }

    @Override
    public AnswerSourceVo getAnswerSource(String deti, String valueOf)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", 1102);
        params.put("userid", FlyApplication.userId);
        params.put("percentage", valueOf);
        params.put("dati", deti);
        String json = ConnectionUtil.post("", params);
        return JSON.parseObject(json, AnswerSourceVo.class);

        // return JSON.parseObject(TestJson.getAnswerSource(),
        // AnswerSourceVo.class);
    }

    @Override
    public RootVo updatePic(String type, String id, String image,
                            String imageType) throws Exception {

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "409");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        params.put("id", id);
        params.put("imgType", imageType);
        params.put("image", image);
        String json = ConnectionUtil.post("", params);
        return JSON.parseObject(json, RootVo.class);
    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-7 下午2:38:45
     * @Description:
     * @type
     * @parameters channel 1 公共、2卫视、 3经济 、4影视、5少儿
     */
    @Override
    public BillVo getPlayBill(int channel) throws Exception {
        String requestPor = "por=202" + "&channel=" + channel;
        String json = ConnectionUtil.send(false, requestPor, "get", null);

        return JSON.parseObject(json, BillVo.class);
    }

    @Override
    public MyCollectionRefreshVo deleteMyCollection(String userid, String type,
                                                    String action, String id) throws Exception {
        String requestPor = "por=501" + "&userid=" + userid + "&type=" + type
                + "&action=" + action + "&id=" + id;
        String json = ConnectionUtil.send(false, requestPor, "get", null);
        return JSON.parseObject(json, MyCollectionRefreshVo.class);

    }

    @Override
    public EnentItemVo getEnentItem(String id) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "301");
        params.put("userid", FlyApplication.userId);
        params.put("id", id);
        // String requestPor = "por=301" + "&userid=" + userid + "&id=" + id;
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, EnentItemVo.class);
    }

    @Override
    public EnentCodeVo getEnentCode(String userid, String id) throws Exception {
        // Map<String, Object> params = new HashMap<String, Object>();
        // params.put("por", "302");
        // params.put("userid", userid);
        // params.put("id", id);
        String requestPor = "por=302" + "&userid=" + userid + "&id=" + id;
        // String json = ConnectionUtil.send(false, "", "post", params);
        String json = ConnectionUtil.send(false, requestPor, "get", null);
        return JSON.parseObject(json, EnentCodeVo.class);
    }

    public AmusementListVo getMapListfortype(String type, String limit1,
                                             String limit2) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "406");
        params.put("type", type);
        params.put("latitude", FlyApplication.latitude);
        params.put("longitude", FlyApplication.longitude);
        params.put("limit1", limit1);
        params.put("limit2", limit2);
        params.put("userid", FlyApplication.userId);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, AmusementListVo.class);
    }

    @Override
    public UserImageVo uploadUserImage(String userId, String img)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "904");
        params.put("userid", userId);
        params.put("img", img);
        params.put("suffix", ".jpg");
        String json = ConnectionUtil.post("", params);
        // String path = "por=904" + "&userid=" + userId + "&img=" +
        // img+"&suffix=jpg";
        // String json = ConnectionUtil.send(false, path, "post", null);
        return JSON.parseObject(json, UserImageVo.class);
    }

    @Override
    public NewsSectionListVo getNewsSectionListVo(boolean isFromCache)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "101");
        params.put("userid", FlyApplication.userId);
        String json;
        if (isFromCache) {
            json = LocalCache.loadFileCache(LocalCache.getFileName(
                    ConnectionUtil.URL, params));
        } else {
            json = ConnectionUtil.send(true, "", "post", params);
        }
        return JSON.parseObject(json, NewsSectionListVo.class);
        // return JSON.parseObject(json, NewsSectionListVo.class);
    }

    @Override
    public NewsListVo getNewsListVo(boolean isFromCache, String id, int pageNo,
                                    int pageSize) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "102");
        params.put("classid", id);
        params.put("limit1", pageNo + "");
        params.put("limit2", pageSize + "");
        String json;
        if (isFromCache) {
            json = LocalCache.loadFileCache(LocalCache.getFileName(
                    ConnectionUtil.URL, params));
        } else {
            json = ConnectionUtil.send(true, "", "post", params);
        }
        return JSON.parseObject(json, NewsListVo.class);
    }

    @Override
    public NewsDetailVo getNewsDetailVo(boolean isFromCache, String id)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "103");
        params.put("id", id);
        params.put("userid", FlyApplication.userId);
        String json;
        if (isFromCache) {
            json = LocalCache.loadFileCache(LocalCache.getFileName(
                    ConnectionUtil.URL, params));
        } else {
            json = ConnectionUtil.send(true, "", "post", params);
        }
        return JSON.parseObject(json, NewsDetailVo.class);
    }

    /**
     * @throws Exception 获取首页信息
     * @author qiwx
     * @createdate 2014-7-9 下午2:22:07
     * @Description:
     * @type
     * @parameters
     */
    @Override
    public HomeInfoVo getHomeInfo() throws Exception {
        // Auto-generated method stub
        String por = "por=100";
        String json = ConnectionUtil.send(false, por, "get", null);
        return JSON.parseObject(json, HomeInfoVo.class);
    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-9 下午5:54:12
     * @Description:
     * @type
     * @parameters
     */
    @Override
    public BroadCastVo getBroadCastInfo() throws Exception {
        String por = "por=203";
        String json = ConnectionUtil.send(false, por, "get", null);
        Log.e("json", json);
        return JSON.parseObject(json, BroadCastVo.class);
    }

    @Override
    public ConsigneeInfoVo getConsigneeInfo(String userid, String log_id)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "804");
        params.put("userid", userid);
        params.put("log_id", log_id);
        // String path = "por=804" + "&userid=" + userid + "&log_id=" + log_id;
        // String json = ConnectionUtil.send(false, path, "post", null);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, ConsigneeInfoVo.class);
    }

    @Override
    public ShareAndPushVo getOrSendVal(String userId, int action, String val)
            throws Exception {
        String params = "por=900" + "&userid=" + userId + "&action=" + action
                + "&val=" + val;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, ShareAndPushVo.class);
    }

    @Override
    public RootVo sendSuggest(String username, String suggestStr,
                              String contactInfo) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "905");
        params.put("username", username);
        params.put("contents", suggestStr);
        if (contactInfo != null)
            params.put("contact_way", contactInfo);
        String json = ConnectionUtil.post("", params);
        // String path = "por=904" + "&userid=" + userId + "&img=" +
        // img+"&suffix=jpg";
        // String json = ConnectionUtil.send(false, path, "post", null);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public GoodsOrderInfoVo getGoodsOrderInfoVo(String type, String type2,
                                                String goods_id) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "802");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        params.put("type2", type2);
        params.put("goods_id", goods_id);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, GoodsOrderInfoVo.class);

    }

    @Override
    public GoodsOrderInfoVo getGoodsOrderInfoVo(String type, String type2,
                                                String goods_id, String user_name, String number, String address,
                                                String remark) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "802");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        params.put("type2", type2);
        params.put("goods_id", goods_id);
        params.put("user_name", user_name);
        params.put("number", number);
        params.put("address", address);
        params.put("remark", remark);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, GoodsOrderInfoVo.class);

    }

    @Override
    public GoodsOrderInfoVo getGoodsOrderInfoVo(String type, String goods_id,
                                                String score, String conten, String user_name, String number,
                                                String address, String remark) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "802");
        params.put("userid", FlyApplication.userId);
        params.put("type", type);
        params.put("type2", "1");
        params.put("goods_id", goods_id);
        params.put("score", score);
        params.put("user_name", user_name);
        params.put("conten", conten);
        params.put("number", number);
        params.put("address", address);
        params.put("remark", remark);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, GoodsOrderInfoVo.class);
    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-10 上午10:24:46
     * @Description:
     * @type
     * @parameters id为请求对象的评论的唯一标识，type 区分1：新闻评论，2:微视听评论 ,娱乐美食此值为null
     * limit1为评论页数，请求页数，limit2为请求条数，0代表默认条数，服务器返回固定八条数据 否则服务器返回
     * limit2条数据
     */
    @Override
    public CommentListVo getCommentList(String id, byte type, byte limit1,
                                        byte limit2) throws Exception {
        String params = null;
        String json;// 返回结果数据
        params = "por=105" + "&id=" + id + "&type=" + type + "&limit1="
                + limit1;
        if (limit2 != 0)
            params = params + "&limit2=" + limit2;
        json = ConnectionUtil.send(false, params, "get", null);

        return JSON.parseObject(json, CommentListVo.class);
    }

    /**
     * @throws Exception
     * @author qiwx
     * @createdate 2014-7-15 上午10:48:46
     * @Description: userid可以为空
     * @type
     * @parameters
     */
    @Override
    public MicProgramBean getLanmuInfo(String id, String userid)
            throws Exception {
        String params = null;
        String json;// 返回结果数据
        params = "por=204" + "&classid=" + id;
        if (TextUtil.stringIsNotNull(userid))
            params = params + "&userid=" + userid;
        json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, MicProgramBean.class);

    }

    @Override
    public RootVo deleteCashGoodActivity(String log_id) throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "806");
        params.put("userid", FlyApplication.userId);
        params.put("log_id", log_id);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public MyGoodVo getMyGoodActivity(String log_id, String goods_id)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "805");
        params.put("userid", FlyApplication.userId);
        params.put("log_id", log_id);
        params.put("goods_id", goods_id);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, MyGoodVo.class);
    }

    @Override
    public VersionVo getVersionInfo() throws Exception {
        String params = "por=902";
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, VersionVo.class);
    }

    @Override
    public AdverVo downLoadAdver() throws Exception {
        String params = "por=906";
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, AdverVo.class);
    }

    @Override
    public UserInfoVo getUserInfo(String id) throws Exception {
        String params = "por=901" + "&userid=" + id;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, UserInfoVo.class);
    }

    @Override
    public EasyFunBeginVo getEasyFunBeginInfo(String userid) throws Exception {
        // Auto-generated method stub
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1110");
        params.put("userid", userid);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, EasyFunBeginVo.class);
    }

    @Override
    public EasyFunEndVo getEasyFunEndInfo(String id, String userid)
            throws Exception {
        // Auto-generated method stub
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1115");
        params.put("userid", userid);
        params.put("id", id);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, EasyFunEndVo.class);
    }

    @Override
    public MessageVo getMessageInfo(String imei, String acttype, String rectype)
            throws Exception {
        // Auto-generated method stub
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1007");
        params.put("identCode", imei); // 设备唯一标识码
        params.put("acttype", acttype);
        params.put("rectype", rectype);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, MessageVo.class);
    }

    @Override
    public TurntableInfoVo getTurntableInfo() throws Exception {
        String params = "por=1200" + "&userid=" + FlyApplication.userId;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, TurntableInfoVo.class);
    }

    @Override
    public TurntableResultVo getTurntableResult(String gain) throws Exception {
        String params = "por=1201" + "&gain=" + gain + "&userid="
                + FlyApplication.userId;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, TurntableResultVo.class);
        // return JSON.parseObject(TestJson.getTurRes(),
        // TurntableResultVo.class);
    }

    @Override
    public MyPrizeVo getMyPrizeInfo() throws Exception {
        String params = "por=1203" + "&userid=" + FlyApplication.userId;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, MyPrizeVo.class);
    }

    @Override
    public AcceptPrizeInfoVo getAcceptInfo(String id) throws Exception {
        String params = "por=1204" + "&userid=" + FlyApplication.userId
                + "&id=" + id;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, AcceptPrizeInfoVo.class);
    }

    @Override
    public TurntableGainVo getTurntableTimes() throws Exception {
        String params = "por=1205" + "&userid=" + FlyApplication.userId;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, TurntableGainVo.class);
    }

    @Override
    public RootVo SubmitInforActivity(String yonghu, String mobile,
                                      String address, String notice, String prizemessageid)
            throws Exception {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("por", "1202");
        params.put("userid", FlyApplication.userId);
        params.put("yonghu", yonghu);
        params.put("mobile", mobile);
        params.put("address", address);
        params.put("notice", notice);
        params.put("prizemessageid", prizemessageid);
        String json = ConnectionUtil.send(false, "", "post", params);
        return JSON.parseObject(json, RootVo.class);
    }

    @Override
    public LockingCheck getLockingCheckNews(String id) throws Exception {
//		Map<String, Object> params = new HashMap<String, Object>();
//		params.put("por", "160");
//		params.put("user_id", id);
//		String json = ConnectionUtil.send(false, "", "post", params);
//		return JSON.parseObject(json, LockingCheck.class);
        String params = "por=160" + "&user_id=" + id;
        String json = ConnectionUtil.send(false, params, "get", null);
        return JSON.parseObject(json, LockingCheck.class);
    }

    @Override
    public LoginVo dumplingLogin(String userId, String userName, String channel, String nickName, String status) throws Exception {
        StringBuilder builder = new StringBuilder();
        builder.append(ConnectionUtil.DUMPLING_LOGIN_URL);
        builder.append("/?por=9000&");
        builder.append("channel=2&");
        builder.append("nickName=" + nickName + "&");
        builder.append("status=" + status + "&");
        builder.append("userId=" + userId + "&");
        builder.append("userName=" + userName);
        String json = ConnectionUtil.send(builder.toString(), "get", null);
        Log.i("请求返回数据", json);
        return JSON.parseObject(json, LoginVo.class);
    }

    @Override
    public RequestCall getNewsListVo2(Object tag, String id, String zid, int pageNo, int pageSize) {
        Map<String, String> params = new HashMap<>();
        params.put("por", "102");
        params.put("classid", "" + id);
        params.put("zclassid", "" + zid);
        params.put("limit1", pageNo + "");
        params.put("limit2", pageSize + "");
        return HttpTools.getInstance().get(tag, ConnectionUtil.URL, params);
    }

    @Override
    public RequestCall getHomeNews(Object tag, int pageNo, int pageSize) {
        Map<String, String> params = new HashMap<>();
        params.put("por", "1021");
        params.put("limit1", pageNo + "");
        params.put("limit2", pageSize + "");
        return HttpTools.getInstance().get(tag, ConnectionUtil.URL, params);
    }

    @Override
    public RequestCall getNewslookNum(Object tag, String id, int type) {
        Map<String, String> params = new HashMap<>();
        params.put("por", "109");
        params.put("type", type + "");
        params.put("classid", id + "");
        return HttpTools.getInstance().get(tag, ConnectionUtil.URL, params);
    }

    @Override
    public RequestCall getMyCollectionNews(Object tag, String userId, int pageNo) {
        String Url = ConnectionUtil.URL + "por=502" + "&userid=" + userId + "&type=3"
                + "&limit1=" + pageNo + "&limit2=" + 10;

        return HttpTools.getInstance().get(tag, Url);
    }

    @Override
    public RequestCall getLiveHome(Object tag) {
        String Url = ConnectionUtil.URL + "por=110";
        return HttpTools.getInstance().get(tag, Url);
    }

    @Override
    public RequestCall getUserJurisdiction(Object tag, String username) {
        String Url = ConnectionUtil.PORTAL_VAILED + username;
        return HttpTools.getInstance().get(tag, Url);
    }

    @Override
    public RequestCall submitLiveComment(Object tag, CommentSubmitVo commentInfo, Context context) {
        Map<String, String> params = new HashMap<>();
        params.put("por", "106");
        params.put("type", commentInfo.getType());
        params.put("userid", FlyApplication.userId);
        params.put("user_img", SharedPreferenceUtil.getString(FlyApplication.context, "photo"));
        params.put("username", SharedPreferenceUtil.getString(context, "username"));
        params.put("nickname", SharedPreferenceUtil.getString(context, "nickname"));
        SpannableString spring = new SpannableString(commentInfo.getContent());
        params.put("content", spring + "");
        params.put("id", commentInfo.getId());
        params.put("state", "1");
        String Url = ConnectionUtil.URL;
        return HttpTools.getInstance().get(tag, Url, params);
    }

    @Override
    public RequestCall getLiveCommentList(Object tag, String id, int pageNo, int pageSize) {
        Map<String, String> params = new HashMap<>();
        params.put("por", "105");
        params.put("type", "4");
        params.put("id", id + "");
        params.put("limit1", pageNo + "");
        params.put("limit2", pageSize + "");
        String Url = ConnectionUtil.URL;
        return HttpTools.getInstance().get(tag, Url, params);
    }

    @Override
    public RequestCall getLookNum(Object tag, String classid, int type) {
        Map<String, String> params = new HashMap<>();
        params.put("por", "111");
        params.put("type", "" + type);
        params.put("classid", classid + "");
        String Url = ConnectionUtil.URL;
        return HttpTools.getInstance().get(tag, Url, params);
    }

    @Override
    public RequestCall getViedoList(Object tag) {
        Map<String, String> params = new HashMap<>();
        params.put("por", "200");
        String Url = ConnectionUtil.URL;
        return HttpTools.getInstance().get(tag, Url, params);
    }


}
